#ifndef __MY_DATE__
#define __MY_DATE__
#include<unordered_map>
#include<pthread.h>
#include"util.hpp"
#include"config.hpp"
namespace cloud
{
    typedef struct BackupInfo{
        bool pack_flag;
        time_t mtime;
        time_t atime;
        size_t fsize;
        std::string real_path;
        std::string url;
        std::string pack_path;
        void NewBackupInfo(const std::string &realpath)
        {
            Config *config=Config::GetInstance();
            std::string packdir=config->GetPackDir();
            std::string packsuffix=config->GetPackFileSuffix();
            std::string download_prefix=config->GetDownloadPrefix();
            FileUtil fu(realpath);

            this->pack_flag=false;
            this->fsize=fu.FileSize();
            this->mtime=fu.LastMTime();
            this->atime=fu.LastATime();
            this->real_path=realpath;
            this->pack_path=packdir+fu.FileName()+packsuffix;
            this->url=download_prefix+fu.FileName();
        }
    }BackupInfo;

    // class DataManager
    // {
    // private:
    //      FileUtil _backup_file;
    //      pthread_rwlock_t _rwlock;
    //      std::unordered_map<std::string, BackupInfo> _table;
    // public:
    //     DataManager();
    //     bool InitLoad();//初始化程序运行时从文件读取数据
    //     bool Storage(); //每次有信息改变则需要持久化存储一次
    //     bool Insert(const std::string &key, const BackupInfo &val);
    //     bool Update(const std::string &key, const BackupInfo &val);
    //     bool GetOneByURL(const std::string &key, BackupInfo *info);
    //     bool GetOneByRealPath(const std::string &key, BackupInfo *info);
    //     bool GetAll(std::vector<BackupInfo> *arry);
    // };
}


#endif